﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
namespace BPM.Web.Shared.Data;

/// <summary>
/// 任务信息---任务详情
/// </summary>
public partial class JobOutput : BaseVM
{
    /// <summary>
    /// 主键Id
    /// </summary>
    [DisplayName("业务号")]
    [Required(ErrorMessage = "业务号不能为空")]
    [JsonPropertyName("id")]
    public long Id { get; set; }

    /// <summary>
    /// 已执行次数
    /// </summary>
    [DisplayName("执行次数")]
    [JsonPropertyName("runNumber")]
    public long? RunNumber { get; set; }

    /// <summary>
    /// 任务状态
    /// </summary>
    [DisplayName("任务状态")]
    [JsonPropertyName("timerStatus")]
    public SpareTimeStatus TimerStatus { get; set; }

    /// <summary>
    /// 异常信息
    /// </summary>
    [DisplayName("异常信息")]
    [JsonPropertyName("exception")]
    public string? Exception { get; set; }

    /// <summary>
    /// 任务名称
    /// </summary>
    [DisplayName("任务名称")]
    [JsonPropertyName("jobName")]
    [Required]
    public string? JobName { get; set; }

    /// <summary>
    /// 只执行一次
    /// </summary>
    [DisplayName("只执行一次")]
    [JsonPropertyName("doOnce")]
    public bool DoOnce { get; set; }

    /// <summary>
    /// 立即执行（默认等待启动）
    /// </summary>
    [DisplayName("立即执行")]
    [JsonPropertyName("startNow")]
    public bool StartNow { get; set; }

    [DisplayName("执行类型")]
    [JsonPropertyName("executeType")]
    [Required]
    public SpareTimeExecuteTypes ExecuteType { get; set; }

    /// <summary>
    /// 执行间隔时间（单位秒）
    /// </summary>
    [DisplayName("执行间隔(秒)")]
    [JsonPropertyName("interval")]
    [Required]
    public int Interval { get; set; }

    /// <summary>
    /// Cron表达式
    /// </summary>
    [DisplayName("任务表达式")]
    [JsonPropertyName("cron")]
    [Required]
    public string? Cron { get; set; }

    /// <summary>
    /// 任务类型
    /// </summary>
    [DisplayName("任务类型")]
    [JsonPropertyName("timerType")]
    [Required]
    public SpareTimeTypes TimerType { get; set; }

    /// <summary>
    /// 请求url
    /// </summary>
    [DisplayName("请求地址")]
    [JsonPropertyName("requestUrl")]
    public string? RequestUrl { get; set; }

    /// <summary>
    /// 请求参数（Post，Put请求用）
    /// </summary>
    [DisplayName("请求参数")]
    [JsonPropertyName("RequestParameters")]
    public string? RequestParameters { get; set; }

    /// <summary>
    /// Headers(可以包含如：Authorization授权认证)
    /// <br/>格式：{"Authorization":"userpassword.."}
    /// </summary>
    [DisplayName("请求头")]
    [JsonPropertyName("headers")]
    public string? Headers { get; set; }

    /// <summary>
    /// 请求类型
    /// </summary>
    [DisplayName("请求类型")]
    [JsonPropertyName("requestType")]
    [Required]
    public RequestTypeEnum RequestType { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [DisplayName("备注")]
    [JsonPropertyName("remark")]
    public string? Remark { get; set; }
}
